using System;
using System.Linq.Expressions;
using System.Windows.Controls.Primitives;
using System.Windows.Data;

namespace FluentSilverlight.Binders
{
    public class ToggleButtonBinder<TModel> : ButtonBaseBinder<ToggleButtonBinder<TModel>, ToggleButton, TModel>
        where TModel : class
    {
        public ToggleButtonBinder(TModel model, ToggleButton control)
            : base(model, control)
        { }

        public ToggleButtonBinder<TModel> IsChecked(Expression<Func<TModel, object>> expression)
        {
            propertyBinder.SetBinding(expression, ToggleButton.IsCheckedProperty, BindingMode.TwoWay);
            return this;
        }

        protected override ToggleButtonBinder<TModel> thisInstance()
        {
            return this;
        }
    }
}